<!DOCTYPE html>
<html>
<!--
Copyright 2012 The Closure Library Authors. All Rights Reserved.

Use of this source code is governed by the Apache License, Version 2.0.
See the COPYING file for details.
-->
<head>
<title>Closure Unit Tests - Logic matchers</title>
<script src="../../base.js"></script>
<script>

goog.require('goog.labs.testing.AllOfMatcher');
goog.require('goog.labs.testing.GreaterThanMatcher');
goog.require('goog.labs.testing.assertThat');
goog.require('goog.testing.jsunit');

</script>
</head>
<body>
<script>

function testAnyOf() {
  goog.labs.testing.assertThat(5, anyOf(greaterThan(4), lessThan(3)),
      '5 > 4 || 5 < 3');
  goog.labs.testing.assertThat(2, anyOf(greaterThan(4), lessThan(3)),
      '2 > 4 || 2 < 3');

  assertMatcherError(function() {
    goog.labs.testing.assertThat(4, anyOf(greaterThan(5), lessThan(2)));
  }, 'anyOf should throw exception when it fails');
}

function testAllOf() {
  goog.labs.testing.assertThat(5, allOf(greaterThan(4), lessThan(6)),
      '5 > 4 && 5 < 6');

  assertMatcherError(function() {
    goog.labs.testing.assertThat(4, allOf(lessThan(5), lessThan(3)));
  }, 'allOf should throw exception when it fails');
}

function testIsNot() {
  goog.labs.testing.assertThat(5, isNot(greaterThan(6)), '5 !> 6');

  assertMatcherError(function() {
    goog.labs.testing.assertThat(4, isNot(greaterThan(3)));
  }, 'isNot should throw exception when it fails');
}

function assertMatcherError(callable, errorString) {
  var e = assertThrows(errorString || 'callable throws exception', callable);
  assertTrue(e instanceof goog.labs.testing.MatcherError);
}

</script>
</body>
</html>
